package com.miyake.dsp.osa.lab;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.miyake.dsp.ComplexArray;
import com.miyake.dsp.ScilabExecute;

public abstract class Calculator {
	abstract public void process();
	abstract public Object getSetting();
	
	private Map<String, ComplexArray> inputMap = new HashMap<String, ComplexArray>();
	private Map<String, ComplexArray> outputMap = new HashMap<String, ComplexArray>();

	public Calculator() {
		super();
	}

	protected Map<String, ComplexArray> getInputMap() {
		return inputMap;
	}

	protected void setInputMap(Map<String, ComplexArray> inputMap) {
		this.inputMap = inputMap;
	}

	protected Map<String, ComplexArray> getOutputMap() {
		return outputMap;
	}

	protected void setOutputMap(Map<String, ComplexArray> outputMap) {
		this.outputMap = outputMap;
	}

	public Set<String> getInputKeySet() {
		return inputMap.keySet();
	}
	
	public Set<String> getOutputKeySet() {
		return outputMap.keySet();
	}
	
	public void setInput(String key, double[] d) {
		this.inputMap.put(key, new ComplexArray(d));
	}
	
	public void setInput(String key, ComplexArray d) {
		this.inputMap.put(key, d);
	}

	public void setOutput(String key, double[] arr) {
		this.outputMap.put(key, new ComplexArray(arr));
	}
	
	public void setOutput(String key, double v) {
		double[] arr = new double[1];
		arr[0] = v;
		this.outputMap.put(key, new ComplexArray(arr));
	}
	
	public void setOutput(String key, ComplexArray d) {
		this.outputMap.put(key, d);
	}
	
	public ComplexArray getInput(String key) {
		return this.inputMap.get(key);
	}
	
	public ComplexArray getOutput(String key) {
		return this.outputMap.get(key);
	}
	
	protected void initInput(String key) {
		this.inputMap.put(key, new ComplexArray(new double[0]));
	}
	
	protected void initOutput(String key) {
		this.outputMap.put(key, new ComplexArray(new double[0]));
	}
	public void clear() {
		clearInput();
		clearOutput();
	}
	public void clearInput() {
		for (String key : this.inputMap.keySet()) {
			this.inputMap.put(key, new ComplexArray(new double[0]));
		}
	}
	public void clearOutput() {
		for (String key : this.outputMap.keySet()) {
			this.outputMap.put(key, new ComplexArray(new double[0]));
		}
	}
}